<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');
  
  JHTML::_('behavior.tooltip');
?>

<form name="adminForm" action="index.php" method="post">
    <div style="width:100%;">
		
        <table>
			<tr>
				<td align="left" width="100%">
					<?php echo JText::_( 'Filter' ); ?>:
					<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />					
                    <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
					<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
				</td>
				<td nowrap="nowrap">
					<?php 
					$count_ele = 0;	
					if($this->lists['filter']){?>
						<?php foreach ($this->lists['filter'] as $row){?>
							<?php $count_ele++; ?>
							<?php echo $row;?>
						<?php 
						if ($count_ele==4)
						{
							echo '</td>';
							echo '</tr>';
							echo '<tr>';
							echo '<td align="left" width="100%">&nbsp';
							echo '</td>';
							echo '<td nowrap="nowrap">';
							$count_ele = 0;
						}
						}
						?>
					<?php }?>
					<select name="is_hotjob" onchange="form.submit()">		
						<option value="" <?php if($this->lists['is_hotjob']==-1) echo 'selected';?>><?php echo '--'.JText::_('Select Premium Post').'--';?></option>				
						<option value="0" <?php if($this->lists['is_hotjob']==0) echo 'selected';?>><?php echo JText::_('No')?></option>						
						<option value="1" <?php if($this->lists['is_hotjob']==1) echo 'selected';?>><?php echo JText::_('Yes')?></option>
					</select>

				</td>

			</tr>
		</table>
       
		<table class="adminlist">
        	<thead>
				<tr>
					<th width="20">
						<?php echo JText::_( 'NUM' ); ?>
					</th>
					<th width="5%"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" /></th>
					<?php
                    for($i = 0, $n = count($this->fieldlist); $i < $n; $i++ ){
                        $field = $this->fieldlist[$i];
                        if($field->is_sortable){
                            $header = JHTML::_('grid.sort',   JText::_($field->label), $field->sort_field_name, @$this->lists['order_Dir'], @$this->lists['order'] );
                        } else {
                            $header = JText::_($field->label);
                        }
                        ?>
                        <th class="title">
                            <?php echo  $header; ?>
                        </th>
                        <?php
                    }
                    ?>
				</tr>
			</thead>
			<tbody>
        	<?php
        	$items = $this->items;
        	$k = 0;
        	$orderNo = 0;
        	$currentTable = '';
        	for($i = 0, $n = count($items); $i < $n; $i++, $orderNo++){
        		$item = $items[$i];
        		$checked 	= JHTML::_('grid.checkedout',   $item, $i );
        		?>
        		<tr class="row<?php echo $k; ?>">
            		<td align="center"><?php echo $this->pagination->getRowOffset($i); ?></td>            	
            		<td align="center"><?php echo $checked; ?></td>
            		<?php
            		
                    for($ii = 0, $nn = count($this->fieldlist); $ii < $nn; $ii++ ){
                        $field = $this->fieldlist[$ii];
                        $field_name = $field->field_name;
                        $nowrap = $field->no_wrap ? "nowrap":"";
                        
                        $text = $field->truncate_length?SmartTrim::trim($item->$field_name,0,$field->truncate_length):$item->$field_name;
	                	$text = $field->clean_format?JFilterOutput::cleanText($text):$text;
	                	
	                	$width_column = ($field->column_width!=0)?"width=\"".$field->column_width."%\"":"";
                        $align="";
                        if($field->field_type == "boolean" ){
                            $align = "align='center'";
                            $text = $this->getToggleLink($field_name, $item, $i);
                        }
                                                
                        if($field->linked){
                            ?>
                            <td <?php echo $align; ?> <?php echo $nowrap; ?> <?php echo $width_column; ?>>
                                <span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Item' );?>">
                                <?php if ($field->is_bold) echo '<strong>'; ?>
                                <a href="<?php echo JRoute::_( 'index.php?option='. JBCOMNAME .'&view=jajobs&task=edit&cid[]='.$item->id ); ?>"><?php echo $text; ?></a>
                                <?php if ($field->is_bold) echo '</strong>'; ?>
                                </span>
                            </td>
                            <?php
                        } else {
                        	global $jbconfig;
                        	if( $field->field_type == "DATE_CAL" || $field->field_type == "DATE"){
		                    		$format = $jbconfig['general']->get("format_date", "%Y-%m-%d");
		                    		$format = str_replace("%", "", $format);		                    		
		                    		if( strpos($text, " ") !== false && $jbconfig['general']->get("posts_show_published_date", "1") == "0" )
		                    			$text = date($format, strtotime($text));
		                    }
                            ?>
                            <td <?php echo $align; ?> <?php echo $nowrap; ?> <?php echo $width_column; ?>>
                            <?php if ($field->is_bold) echo '<strong>'; ?>
                                <?php echo  $text; ?>
                            <?php if ($field->is_bold) echo '</strong>'; ?>
                            </td>
                            <?php
                        }
                    }
                    ?>
            	</tr>
        	<?php
        		$k = 1 - $k;
			}
        	?>
        	<tbody>
        	<tfoot>
				<tr>
					<td colspan="<?php echo count($this->fieldlist) + 2; ?>" style="text-align:center;">
                        <?php echo $this->pagination->getListFooter(); ?>
                    </td>
				</tr>
			</tfoot>
		</table>
        
	</div>
	<input type="hidden" name="filter_status" value="<?php echo JRequest::getVar('filter_status'); ?>" />
	<input type="hidden" name="filter_duration" value="<?php echo JRequest::getVar('filter_duration'); ?>" />
	<input type="hidden" name="option" value="<?php echo $this->lists['option']; ?>" />
	<input type="hidden" name="view" value="jajobs" />
    <input type="hidden" name="task" value="" />
	<!--<input type="hidden" name="table_name" value="<?php echo $this->table_name;?>" />-->
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>	
 </form>
